package cn.uniquesoft.controller;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.uniquesoft.controller.base.BaseController;
import cn.uniquesoft.service.IMenuService;
import cn.uniquesoft.util.MenuUtil;
import cn.uniquesoft.vo.AnswerVO;
import cn.uniquesoft.vo.MenuTreeVO;
import cn.uniquesoft.vo.MenuVO;
import cn.uniquesoft.vo.RoleMenuVO;

@SuppressWarnings("unused")
@Controller
@RequestMapping(value = "/menu")
public class MenuController extends BaseController<MenuVO> {

	private static Logger Log = LoggerFactory.getLogger(MenuController.class);

	@Autowired
	private IMenuService menuService;

	public MenuController(IMenuService menuService) {
		super();
		this.menuService = menuService;
		this.baseService = menuService;
		this.indexName = "menu/index";
	}

	@RequestMapping(value = "/treeQuery")
	@ResponseBody
	public List<MenuTreeVO> treeQuery(MenuVO item) {
		List<MenuVO> menuList = this.menuService.findAll(item);
		return MenuUtil.getMenuTreeList(menuList);
	}

	
	@RequestMapping(value = "/getMenuIds")
	@ResponseBody
	public AnswerVO getMenuIds(int rid) {
		AnswerVO answerVO=new AnswerVO();
		RoleMenuVO rmitem=this.menuService.getItemByRid(rid);
		String menuids=rmitem.getImenuid();
		answerVO.setData(menuids);
		return answerVO;
	}

}
